#!/bin/bash
PidFile=".pid"
if [ ! -f $PidFile ]; then
    echo "当前未运行 (没有找到pid文件)"
    exit $?
fi
pid=`tail -1 $PidFile`
if [ "x" == "x$pid" ]; then
    echo "当前未运行 (存在pid文件, 但是其中没有任何pid)"
    exit $?
fi
ret=`ps aux | awk '{print $2}' | grep $pid`
if [ "x" == "x$ret" ]; then
    echo "当前未运行 (目标pid = $pid)"
    exit $?
fi
echo "正在停止 (目标pid=$pid)"
kill -9 $pid
echo "DataService已停止"
